<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>keyhandler_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_events_keyhandler_test.js.html">keyhandler_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2008 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.events.KeyEventTest&#39;);
<a name="line16"></a>goog.setTestOnly(&#39;goog.events.KeyEventTest&#39;);
<a name="line17"></a>
<a name="line18"></a>goog.require(&#39;goog.dom&#39;);
<a name="line19"></a>goog.require(&#39;goog.events&#39;);
<a name="line20"></a>goog.require(&#39;goog.events.BrowserEvent&#39;);
<a name="line21"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line22"></a>goog.require(&#39;goog.events.KeyCodes&#39;);
<a name="line23"></a>goog.require(&#39;goog.events.KeyHandler&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.events&#39;);
<a name="line25"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line26"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line27"></a>
<a name="line28"></a>function setUp() {
<a name="line29"></a>  // Have this based on a fictitious DOCUMENT_MODE constant.
<a name="line30"></a>  goog.userAgent.isDocumentMode = function(mode) {
<a name="line31"></a>    return mode &lt;= goog.userAgent.DOCUMENT_MODE;
<a name="line32"></a>  };
<a name="line33"></a>}
<a name="line34"></a>
<a name="line35"></a>
<a name="line36"></a>/**
<a name="line37"></a> * Tests the key handler for the IE 8 and lower behavior.
<a name="line38"></a> */
<a name="line39"></a>function testIe8StyleKeyHandling() {
<a name="line40"></a>  goog.userAgent.OPERA = false;
<a name="line41"></a>  goog.userAgent.IE = true;
<a name="line42"></a>  goog.userAgent.GECKO = false;
<a name="line43"></a>  goog.userAgent.CAMINO = false;
<a name="line44"></a>  goog.userAgent.WEBKIT = false;
<a name="line45"></a>  goog.userAgent.MAC = false;
<a name="line46"></a>  goog.userAgent.WINDOWS = true;
<a name="line47"></a>  goog.userAgent.LINUX = false;
<a name="line48"></a>  goog.userAgent.VERSION = 8;
<a name="line49"></a>  goog.userAgent.DOCUMENT_MODE = 8;
<a name="line50"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = true;
<a name="line51"></a>
<a name="line52"></a>  assertIe8StyleKeyHandling();
<a name="line53"></a>}
<a name="line54"></a>
<a name="line55"></a>
<a name="line56"></a>/**
<a name="line57"></a> * Tests the key handler for the IE 8 and lower behavior.
<a name="line58"></a> */
<a name="line59"></a>function testIe8StyleKeyHandlingInIe9DocumentMode() {
<a name="line60"></a>  goog.userAgent.OPERA = false;
<a name="line61"></a>  goog.userAgent.IE = true;
<a name="line62"></a>  goog.userAgent.GECKO = false;
<a name="line63"></a>  goog.userAgent.CAMINO = false;
<a name="line64"></a>  goog.userAgent.WEBKIT = false;
<a name="line65"></a>  goog.userAgent.MAC = false;
<a name="line66"></a>  goog.userAgent.WINDOWS = true;
<a name="line67"></a>  goog.userAgent.LINUX = false;
<a name="line68"></a>  goog.userAgent.VERSION = 9; // Try IE9 in IE8 document mode.
<a name="line69"></a>  goog.userAgent.DOCUMENT_MODE = 8;
<a name="line70"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = true;
<a name="line71"></a>
<a name="line72"></a>  assertIe8StyleKeyHandling();
<a name="line73"></a>}
<a name="line74"></a>
<a name="line75"></a>function assertIe8StyleKeyHandling() {
<a name="line76"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line77"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line78"></a>      function(e) { keyEvent = e; });
<a name="line79"></a>
<a name="line80"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line81"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line82"></a>  assertEquals(&#39;Enter should fire a key event with the keycode 13&#39;,
<a name="line83"></a>               goog.events.KeyCodes.ENTER,
<a name="line84"></a>               keyEvent.keyCode);
<a name="line85"></a>  assertEquals(&#39;Enter should fire a key event with the charcode 0&#39;,
<a name="line86"></a>               0,
<a name="line87"></a>               keyEvent.charCode);
<a name="line88"></a>
<a name="line89"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ESC);
<a name="line90"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ESC);
<a name="line91"></a>  assertEquals(&#39;Esc should fire a key event with the keycode 27&#39;,
<a name="line92"></a>               goog.events.KeyCodes.ESC,
<a name="line93"></a>               keyEvent.keyCode);
<a name="line94"></a>  assertEquals(&#39;Esc should fire a key event with the charcode 0&#39;,
<a name="line95"></a>               0,
<a name="line96"></a>               keyEvent.charCode);
<a name="line97"></a>
<a name="line98"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.UP);
<a name="line99"></a>  assertEquals(&#39;Up should fire a key event with the keycode 38&#39;,
<a name="line100"></a>               goog.events.KeyCodes.UP,
<a name="line101"></a>               keyEvent.keyCode);
<a name="line102"></a>  assertEquals(&#39;Up should fire a key event with the charcode 0&#39;,
<a name="line103"></a>               0,
<a name="line104"></a>               keyEvent.charCode);
<a name="line105"></a>
<a name="line106"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.SEVEN, undefined, undefined,
<a name="line107"></a>      undefined, undefined, true);
<a name="line108"></a>  fireKeyPress(keyHandler, 38, undefined, undefined, undefined, undefined,
<a name="line109"></a>      true);
<a name="line110"></a>  assertEquals(&#39;Shift+7 should fire a key event with the keycode 55&#39;,
<a name="line111"></a>               goog.events.KeyCodes.SEVEN,
<a name="line112"></a>               keyEvent.keyCode);
<a name="line113"></a>  assertEquals(&#39;Shift+7 should fire a key event with the charcode 38&#39;,
<a name="line114"></a>               38,
<a name="line115"></a>               keyEvent.charCode);
<a name="line116"></a>
<a name="line117"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line118"></a>  fireKeyPress(keyHandler, 97);
<a name="line119"></a>  assertEquals(&#39;Lower case a should fire a key event with the keycode 65&#39;,
<a name="line120"></a>               goog.events.KeyCodes.A,
<a name="line121"></a>               keyEvent.keyCode);
<a name="line122"></a>  assertEquals(&#39;Lower case a should fire a key event with the charcode 97&#39;,
<a name="line123"></a>               97,
<a name="line124"></a>               keyEvent.charCode);
<a name="line125"></a>
<a name="line126"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line127"></a>  fireKeyPress(keyHandler, 65);
<a name="line128"></a>  assertEquals(&#39;Upper case A should fire a key event with the keycode 65&#39;,
<a name="line129"></a>               goog.events.KeyCodes.A,
<a name="line130"></a>               keyEvent.keyCode);
<a name="line131"></a>  assertEquals(&#39;Upper case A should fire a key event with the charcode 65&#39;,
<a name="line132"></a>               65,
<a name="line133"></a>               keyEvent.charCode);
<a name="line134"></a>
<a name="line135"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line136"></a>  assertEquals(&#39;Delete should fire a key event with the keycode 46&#39;,
<a name="line137"></a>               goog.events.KeyCodes.DELETE,
<a name="line138"></a>               keyEvent.keyCode);
<a name="line139"></a>  assertEquals(&#39;Delete should fire a key event with the charcode 0&#39;,
<a name="line140"></a>               0,
<a name="line141"></a>               keyEvent.charCode);
<a name="line142"></a>
<a name="line143"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.PERIOD);
<a name="line144"></a>  fireKeyPress(keyHandler, 46);
<a name="line145"></a>  assertEquals(&#39;Period should fire a key event with the keycode 190&#39;,
<a name="line146"></a>               goog.events.KeyCodes.PERIOD,
<a name="line147"></a>               keyEvent.keyCode);
<a name="line148"></a>  assertEquals(&#39;Period should fire a key event with the charcode 46&#39;,
<a name="line149"></a>               46,
<a name="line150"></a>               keyEvent.charCode);
<a name="line151"></a>
<a name="line152"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.CTRL);
<a name="line153"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line154"></a>  assertEquals(&#39;A with control down should fire a key event&#39;,
<a name="line155"></a>               goog.events.KeyCodes.A,
<a name="line156"></a>               keyEvent.keyCode);
<a name="line157"></a>
<a name="line158"></a>  // On IE, when Ctrl+&lt;key&gt; is held down, there is a KEYDOWN, a KEYPRESS, and
<a name="line159"></a>  // then a series of KEYDOWN events for each repeat.
<a name="line160"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.B, undefined, undefined, true);
<a name="line161"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.B, undefined, undefined,
<a name="line162"></a>      true);
<a name="line163"></a>  assertEquals(&#39;B with control down should fire a key event&#39;,
<a name="line164"></a>               goog.events.KeyCodes.B,
<a name="line165"></a>               keyEvent.keyCode);
<a name="line166"></a>  assertTrue(&#39;Ctrl should be down.&#39;, keyEvent.ctrlKey);
<a name="line167"></a>  assertFalse(&#39;Should not have repeat=true on the first key press.&#39;,
<a name="line168"></a>      keyEvent.repeat);
<a name="line169"></a>  // Fire one repeated keydown event.
<a name="line170"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.B, undefined, undefined, true);
<a name="line171"></a>  assertEquals(&#39;A with control down should fire a key event&#39;,
<a name="line172"></a>               goog.events.KeyCodes.B,
<a name="line173"></a>               keyEvent.keyCode);
<a name="line174"></a>  assertTrue(&#39;Should have repeat=true on key repeat.&#39;,
<a name="line175"></a>      keyEvent.repeat);
<a name="line176"></a>  assertTrue(&#39;Ctrl should be down.&#39;, keyEvent.ctrlKey);
<a name="line177"></a>}
<a name="line178"></a>
<a name="line179"></a>
<a name="line180"></a>/**
<a name="line181"></a> * Tests special cases for IE9.
<a name="line182"></a> */
<a name="line183"></a>function testIe9StyleKeyHandling() {
<a name="line184"></a>  goog.userAgent.OPERA = false;
<a name="line185"></a>  goog.userAgent.IE = true;
<a name="line186"></a>  goog.userAgent.GECKO = false;
<a name="line187"></a>  goog.userAgent.CAMINO = false;
<a name="line188"></a>  goog.userAgent.WEBKIT = false;
<a name="line189"></a>  goog.userAgent.MAC = false;
<a name="line190"></a>  goog.userAgent.WINDOWS = true;
<a name="line191"></a>  goog.userAgent.LINUX = false;
<a name="line192"></a>  goog.userAgent.VERSION = 9;
<a name="line193"></a>  goog.userAgent.DOCUMENT_MODE = 9;
<a name="line194"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = true;
<a name="line195"></a>
<a name="line196"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line197"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line198"></a>      function(e) { keyEvent = e; });
<a name="line199"></a>
<a name="line200"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line201"></a>  fireKeyUp(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line202"></a>  assertEquals(&#39;Enter should fire a key event with the keycode 13&#39;,
<a name="line203"></a>               goog.events.KeyCodes.ENTER,
<a name="line204"></a>               keyEvent.keyCode);
<a name="line205"></a>  assertEquals(&#39;Enter should fire a key event with the charcode 0&#39;,
<a name="line206"></a>               0,
<a name="line207"></a>               keyEvent.charCode);
<a name="line208"></a>}
<a name="line209"></a>
<a name="line210"></a>
<a name="line211"></a>/**
<a name="line212"></a> * Tests the key handler for the Gecko behavior.
<a name="line213"></a> */
<a name="line214"></a>function testGeckoStyleKeyHandling() {
<a name="line215"></a>  goog.userAgent.OPERA = false;
<a name="line216"></a>  goog.userAgent.IE = false;
<a name="line217"></a>  goog.userAgent.GECKO = true;
<a name="line218"></a>  goog.userAgent.CAMINO = false;
<a name="line219"></a>  goog.userAgent.WEBKIT = false;
<a name="line220"></a>  goog.userAgent.MAC = false;
<a name="line221"></a>  goog.userAgent.WINDOWS = true;
<a name="line222"></a>  goog.userAgent.LINUX = false;
<a name="line223"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = false;
<a name="line224"></a>
<a name="line225"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line226"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line227"></a>      function(e) { keyEvent = e; });
<a name="line228"></a>
<a name="line229"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line230"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line231"></a>  assertEquals(&#39;Enter should fire a key event with the keycode 13&#39;,
<a name="line232"></a>               goog.events.KeyCodes.ENTER,
<a name="line233"></a>               keyEvent.keyCode);
<a name="line234"></a>  assertEquals(&#39;Enter should fire a key event with the charcode 0&#39;,
<a name="line235"></a>               0,
<a name="line236"></a>               keyEvent.charCode);
<a name="line237"></a>
<a name="line238"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ESC);
<a name="line239"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ESC);
<a name="line240"></a>  assertEquals(&#39;Esc should fire a key event with the keycode 27&#39;,
<a name="line241"></a>               goog.events.KeyCodes.ESC,
<a name="line242"></a>               keyEvent.keyCode);
<a name="line243"></a>  assertEquals(&#39;Esc should fire a key event with the charcode 0&#39;,
<a name="line244"></a>               0,
<a name="line245"></a>               keyEvent.charCode);
<a name="line246"></a>
<a name="line247"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.UP);
<a name="line248"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.UP);
<a name="line249"></a>  assertEquals(&#39;Up should fire a key event with the keycode 38&#39;,
<a name="line250"></a>               goog.events.KeyCodes.UP,
<a name="line251"></a>               keyEvent.keyCode);
<a name="line252"></a>  assertEquals(&#39;Up should fire a key event with the charcode 0&#39;,
<a name="line253"></a>               0,
<a name="line254"></a>               keyEvent.charCode);
<a name="line255"></a>
<a name="line256"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.SEVEN, undefined, undefined,
<a name="line257"></a>      undefined, undefined, true);
<a name="line258"></a>  fireKeyPress(keyHandler, undefined, 38, undefined, undefined, undefined,
<a name="line259"></a>      true);
<a name="line260"></a>  assertEquals(&#39;Shift+7 should fire a key event with the keycode 55&#39;,
<a name="line261"></a>               goog.events.KeyCodes.SEVEN,
<a name="line262"></a>               keyEvent.keyCode);
<a name="line263"></a>  assertEquals(&#39;Shift+7 should fire a key event with the charcode 38&#39;,
<a name="line264"></a>               38,
<a name="line265"></a>               keyEvent.charCode);
<a name="line266"></a>
<a name="line267"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line268"></a>  fireKeyPress(keyHandler, undefined, 97);
<a name="line269"></a>  assertEquals(&#39;Lower case a should fire a key event with the keycode 65&#39;,
<a name="line270"></a>               goog.events.KeyCodes.A,
<a name="line271"></a>               keyEvent.keyCode);
<a name="line272"></a>  assertEquals(&#39;Lower case a should fire a key event with the charcode 97&#39;,
<a name="line273"></a>               97,
<a name="line274"></a>               keyEvent.charCode);
<a name="line275"></a>
<a name="line276"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line277"></a>  fireKeyPress(keyHandler, undefined, 65);
<a name="line278"></a>  assertEquals(&#39;Upper case A should fire a key event with the keycode 65&#39;,
<a name="line279"></a>               goog.events.KeyCodes.A,
<a name="line280"></a>               keyEvent.keyCode);
<a name="line281"></a>  assertEquals(&#39;Upper case A should fire a key event with the charcode 65&#39;,
<a name="line282"></a>               65,
<a name="line283"></a>               keyEvent.charCode);
<a name="line284"></a>
<a name="line285"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line286"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line287"></a>  assertEquals(&#39;Delete should fire a key event with the keycode 46&#39;,
<a name="line288"></a>               goog.events.KeyCodes.DELETE,
<a name="line289"></a>               keyEvent.keyCode);
<a name="line290"></a>  assertEquals(&#39;Delete should fire a key event with the charcode 0&#39;,
<a name="line291"></a>               0,
<a name="line292"></a>               keyEvent.charCode);
<a name="line293"></a>
<a name="line294"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.PERIOD);
<a name="line295"></a>  fireKeyPress(keyHandler, undefined, 46);
<a name="line296"></a>  assertEquals(&#39;Period should fire a key event with the keycode 190&#39;,
<a name="line297"></a>               goog.events.KeyCodes.PERIOD,
<a name="line298"></a>               keyEvent.keyCode);
<a name="line299"></a>  assertEquals(&#39;Period should fire a key event with the charcode 46&#39;,
<a name="line300"></a>               46,
<a name="line301"></a>               keyEvent.charCode);
<a name="line302"></a>}
<a name="line303"></a>
<a name="line304"></a>
<a name="line305"></a>/**
<a name="line306"></a> * Tests the key handler for the Safari 3 behavior.
<a name="line307"></a> */
<a name="line308"></a>function testSafari3StyleKeyHandling() {
<a name="line309"></a>  goog.userAgent.OPERA = false;
<a name="line310"></a>  goog.userAgent.IE = false;
<a name="line311"></a>  goog.userAgent.GECKO = false;
<a name="line312"></a>  goog.userAgent.CAMINO = false;
<a name="line313"></a>  goog.userAgent.WEBKIT = true;
<a name="line314"></a>  goog.userAgent.MAC = true;
<a name="line315"></a>  goog.userAgent.WINDOWS = false;
<a name="line316"></a>  goog.userAgent.LINUX = false;
<a name="line317"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = true;
<a name="line318"></a>  goog.userAgent.VERSION = 525.3;
<a name="line319"></a>
<a name="line320"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line321"></a>  // Make sure all events are caught while testing
<a name="line322"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line323"></a>      function(e) { keyEvent = e; });
<a name="line324"></a>
<a name="line325"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line326"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line327"></a>  assertEquals(&#39;Enter should fire a key event with the keycode 13&#39;,
<a name="line328"></a>               goog.events.KeyCodes.ENTER,
<a name="line329"></a>               keyEvent.keyCode);
<a name="line330"></a>  assertEquals(&#39;Enter should fire a key event with the charcode 0&#39;,
<a name="line331"></a>               0,
<a name="line332"></a>               keyEvent.charCode);
<a name="line333"></a>  fireKeyUp(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line334"></a>
<a name="line335"></a>  // Add a listener to ensure that an extra ENTER event is not dispatched
<a name="line336"></a>  // by a subsequent keypress.
<a name="line337"></a>  var enterCheck = goog.events.listen(keyHandler,
<a name="line338"></a>      goog.events.KeyHandler.EventType.KEY,
<a name="line339"></a>      function(e) {
<a name="line340"></a>        assertNotEquals(&#39;Unexpected ENTER keypress dispatched&#39;,
<a name="line341"></a>            e.keyCode, goog.events.KeyCodes.ENTER);
<a name="line342"></a>      });
<a name="line343"></a>
<a name="line344"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ESC);
<a name="line345"></a>  assertEquals(&#39;Esc should fire a key event with the keycode 27&#39;,
<a name="line346"></a>               goog.events.KeyCodes.ESC,
<a name="line347"></a>               keyEvent.keyCode);
<a name="line348"></a>  assertEquals(&#39;Esc should fire a key event with the charcode 0&#39;,
<a name="line349"></a>               0,
<a name="line350"></a>               keyEvent.charCode);
<a name="line351"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ESC);
<a name="line352"></a>  goog.events.unlistenByKey(enterCheck);
<a name="line353"></a>
<a name="line354"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.UP);
<a name="line355"></a>  assertEquals(&#39;Up should fire a key event with the keycode 38&#39;,
<a name="line356"></a>               goog.events.KeyCodes.UP,
<a name="line357"></a>               keyEvent.keyCode);
<a name="line358"></a>  assertEquals(&#39;Up should fire a key event with the charcode 0&#39;,
<a name="line359"></a>               0,
<a name="line360"></a>               keyEvent.charCode);
<a name="line361"></a>
<a name="line362"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.SEVEN, undefined, undefined,
<a name="line363"></a>      undefined, undefined, true);
<a name="line364"></a>  fireKeyPress(keyHandler, 38, 38, undefined, undefined, undefined, true);
<a name="line365"></a>  assertEquals(&#39;Shift+7 should fire a key event with the keycode 55&#39;,
<a name="line366"></a>               goog.events.KeyCodes.SEVEN,
<a name="line367"></a>               keyEvent.keyCode);
<a name="line368"></a>  assertEquals(&#39;Shift+7 should fire a key event with the charcode 38&#39;,
<a name="line369"></a>               38,
<a name="line370"></a>               keyEvent.charCode);
<a name="line371"></a>
<a name="line372"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line373"></a>  fireKeyPress(keyHandler, 97, 97);
<a name="line374"></a>  assertEquals(&#39;Lower case a should fire a key event with the keycode 65&#39;,
<a name="line375"></a>               goog.events.KeyCodes.A,
<a name="line376"></a>               keyEvent.keyCode);
<a name="line377"></a>  assertEquals(&#39;Lower case a should fire a key event with the charcode 97&#39;,
<a name="line378"></a>               97,
<a name="line379"></a>               keyEvent.charCode);
<a name="line380"></a>
<a name="line381"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line382"></a>  fireKeyPress(keyHandler, 65, 65);
<a name="line383"></a>  assertEquals(&#39;Upper case A should fire a key event with the keycode 65&#39;,
<a name="line384"></a>               goog.events.KeyCodes.A,
<a name="line385"></a>               keyEvent.keyCode);
<a name="line386"></a>  assertEquals(&#39;Upper case A should fire a key event with the charcode 65&#39;,
<a name="line387"></a>               65,
<a name="line388"></a>               keyEvent.charCode);
<a name="line389"></a>
<a name="line390"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.CTRL);
<a name="line391"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A, null, null, true /*ctrl*/);
<a name="line392"></a>  assertEquals(&#39;A with control down should fire a key event&#39;,
<a name="line393"></a>               goog.events.KeyCodes.A,
<a name="line394"></a>               keyEvent.keyCode);
<a name="line395"></a>
<a name="line396"></a>  // Test that Alt-Tab outside the window doesn&#39;t break things.
<a name="line397"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ALT);
<a name="line398"></a>  keyEvent.keyCode = -1;  // Reset the event.
<a name="line399"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line400"></a>  assertEquals(&#39;Should not have dispatched an Alt-A&#39;, -1, keyEvent.keyCode);
<a name="line401"></a>  fireKeyPress(keyHandler, 65, 65);
<a name="line402"></a>  assertEquals(&#39;Alt should be ignored since it isn\&#39;t currently depressed&#39;,
<a name="line403"></a>               goog.events.KeyCodes.A,
<a name="line404"></a>               keyEvent.keyCode);
<a name="line405"></a>
<a name="line406"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line407"></a>  assertEquals(&#39;Delete should fire a key event with the keycode 46&#39;,
<a name="line408"></a>               goog.events.KeyCodes.DELETE,
<a name="line409"></a>               keyEvent.keyCode);
<a name="line410"></a>  assertEquals(&#39;Delete should fire a key event with the charcode 0&#39;,
<a name="line411"></a>               0,
<a name="line412"></a>               keyEvent.charCode);
<a name="line413"></a>
<a name="line414"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.PERIOD);
<a name="line415"></a>  fireKeyPress(keyHandler, 46, 46);
<a name="line416"></a>  assertEquals(&#39;Period should fire a key event with the keycode 190&#39;,
<a name="line417"></a>               goog.events.KeyCodes.PERIOD,
<a name="line418"></a>               keyEvent.keyCode);
<a name="line419"></a>  assertEquals(&#39;Period should fire a key event with the charcode 46&#39;,
<a name="line420"></a>               46,
<a name="line421"></a>               keyEvent.charCode);
<a name="line422"></a>
<a name="line423"></a>  // Safari sends zero key code for non-latin characters.
<a name="line424"></a>  fireKeyDown(keyHandler, 0, 0);
<a name="line425"></a>  fireKeyPress(keyHandler, 1092, 1092);
<a name="line426"></a>  assertEquals(&#39;Cyrillic small letter &quot;Ef&quot; should fire a key event with &#39; +
<a name="line427"></a>                   &#39;the keycode 0&#39;,
<a name="line428"></a>               0,
<a name="line429"></a>               keyEvent.keyCode);
<a name="line430"></a>  assertEquals(&#39;Cyrillic small letter &quot;Ef&quot; should fire a key event with &#39; +
<a name="line431"></a>                   &#39;the charcode 1092&#39;,
<a name="line432"></a>               1092,
<a name="line433"></a>               keyEvent.charCode);
<a name="line434"></a>}
<a name="line435"></a>
<a name="line436"></a>
<a name="line437"></a>/**
<a name="line438"></a> * Tests the key handler for the Opera behavior.
<a name="line439"></a> */
<a name="line440"></a>function testOperaStyleKeyHandling() {
<a name="line441"></a>  goog.userAgent.OPERA = true;
<a name="line442"></a>  goog.userAgent.IE = false;
<a name="line443"></a>  goog.userAgent.GECKO = false;
<a name="line444"></a>  goog.userAgent.CAMINO = false;
<a name="line445"></a>  goog.userAgent.WEBKIT = false;
<a name="line446"></a>  goog.userAgent.MAC = false;
<a name="line447"></a>  goog.userAgent.WINDOWS = true;
<a name="line448"></a>  goog.userAgent.LINUX = false;
<a name="line449"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = false;
<a name="line450"></a>
<a name="line451"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line452"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line453"></a>      function(e) { keyEvent = e; });
<a name="line454"></a>
<a name="line455"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line456"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ENTER);
<a name="line457"></a>  assertEquals(&#39;Enter should fire a key event with the keycode 13&#39;,
<a name="line458"></a>               goog.events.KeyCodes.ENTER,
<a name="line459"></a>               keyEvent.keyCode);
<a name="line460"></a>  assertEquals(&#39;Enter should fire a key event with the charcode 0&#39;,
<a name="line461"></a>               0,
<a name="line462"></a>               keyEvent.charCode);
<a name="line463"></a>
<a name="line464"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.ESC);
<a name="line465"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.ESC);
<a name="line466"></a>  assertEquals(&#39;Esc should fire a key event with the keycode 27&#39;,
<a name="line467"></a>               goog.events.KeyCodes.ESC,
<a name="line468"></a>               keyEvent.keyCode);
<a name="line469"></a>  assertEquals(&#39;Esc should fire a key event with the charcode 0&#39;,
<a name="line470"></a>               0,
<a name="line471"></a>               keyEvent.charCode);
<a name="line472"></a>
<a name="line473"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.UP);
<a name="line474"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.UP);
<a name="line475"></a>  assertEquals(&#39;Up should fire a key event with the keycode 38&#39;,
<a name="line476"></a>               goog.events.KeyCodes.UP,
<a name="line477"></a>               keyEvent.keyCode);
<a name="line478"></a>  assertEquals(&#39;Up should fire a key event with the charcode 0&#39;,
<a name="line479"></a>               0,
<a name="line480"></a>               keyEvent.charCode);
<a name="line481"></a>
<a name="line482"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.SEVEN, undefined, undefined,
<a name="line483"></a>      undefined, undefined, true);
<a name="line484"></a>  fireKeyPress(keyHandler, 38, undefined, undefined, undefined, undefined,
<a name="line485"></a>      true);
<a name="line486"></a>  assertEquals(&#39;Shift+7 should fire a key event with the keycode 55&#39;,
<a name="line487"></a>               goog.events.KeyCodes.SEVEN,
<a name="line488"></a>               keyEvent.keyCode);
<a name="line489"></a>  assertEquals(&#39;Shift+7 should fire a key event with the charcode 38&#39;,
<a name="line490"></a>               38,
<a name="line491"></a>               keyEvent.charCode);
<a name="line492"></a>
<a name="line493"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line494"></a>  fireKeyPress(keyHandler, 97);
<a name="line495"></a>  assertEquals(&#39;Lower case a should fire a key event with the keycode 65&#39;,
<a name="line496"></a>               goog.events.KeyCodes.A,
<a name="line497"></a>               keyEvent.keyCode);
<a name="line498"></a>  assertEquals(&#39;Lower case a should fire a key event with the charcode 97&#39;,
<a name="line499"></a>               97,
<a name="line500"></a>               keyEvent.charCode);
<a name="line501"></a>
<a name="line502"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A);
<a name="line503"></a>  fireKeyPress(keyHandler, 65);
<a name="line504"></a>  assertEquals(&#39;Upper case A should fire a key event with the keycode 65&#39;,
<a name="line505"></a>               goog.events.KeyCodes.A,
<a name="line506"></a>               keyEvent.keyCode);
<a name="line507"></a>  assertEquals(&#39;Upper case A should fire a key event with the charcode 65&#39;,
<a name="line508"></a>               65,
<a name="line509"></a>               keyEvent.charCode);
<a name="line510"></a>
<a name="line511"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line512"></a>  fireKeyPress(keyHandler, goog.events.KeyCodes.DELETE);
<a name="line513"></a>  assertEquals(&#39;Delete should fire a key event with the keycode 46&#39;,
<a name="line514"></a>               goog.events.KeyCodes.DELETE,
<a name="line515"></a>               keyEvent.keyCode);
<a name="line516"></a>  assertEquals(&#39;Delete should fire a key event with the charcode 0&#39;,
<a name="line517"></a>               0,
<a name="line518"></a>               keyEvent.charCode);
<a name="line519"></a>
<a name="line520"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.PERIOD);
<a name="line521"></a>  fireKeyPress(keyHandler, 46);
<a name="line522"></a>  assertEquals(&#39;Period should fire a key event with the keycode 190&#39;,
<a name="line523"></a>               goog.events.KeyCodes.PERIOD,
<a name="line524"></a>               keyEvent.keyCode);
<a name="line525"></a>  assertEquals(&#39;Period should fire a key event with the charcode 46&#39;,
<a name="line526"></a>               46,
<a name="line527"></a>               keyEvent.charCode);
<a name="line528"></a>}
<a name="line529"></a>
<a name="line530"></a>function testGeckoOnMacAltHandling() {
<a name="line531"></a>  goog.userAgent.OPERA = false;
<a name="line532"></a>  goog.userAgent.IE = false;
<a name="line533"></a>  goog.userAgent.GECKO = true;
<a name="line534"></a>  goog.userAgent.CAMINO = false;
<a name="line535"></a>  goog.userAgent.WEBKIT = false;
<a name="line536"></a>  goog.userAgent.MAC = true;
<a name="line537"></a>  goog.userAgent.WINDOWS = false;
<a name="line538"></a>  goog.userAgent.LINUX = false;
<a name="line539"></a>  goog.events.KeyHandler.SAVE_ALT_FOR_KEYPRESS_ = true;
<a name="line540"></a>
<a name="line541"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line542"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line543"></a>      function(e) { keyEvent = e; });
<a name="line544"></a>
<a name="line545"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.COMMA, 0, null, false,
<a name="line546"></a>      true, false);
<a name="line547"></a>  fireKeyPress(keyHandler, 0, 8804, null, false, false, false);
<a name="line548"></a>  assertEquals(&#39;should fire a key event with COMMA&#39;,
<a name="line549"></a>      goog.events.KeyCodes.COMMA,
<a name="line550"></a>      keyEvent.keyCode);
<a name="line551"></a>  assertEquals(&#39;should fire a key event with alt key set&#39;,
<a name="line552"></a>      true,
<a name="line553"></a>      keyEvent.altKey);
<a name="line554"></a>
<a name="line555"></a>  // Scenario: alt down, a down, a press, a up (should say alt is true),
<a name="line556"></a>  // alt up.
<a name="line557"></a>  keyEvent = undefined;
<a name="line558"></a>  fireKeyDown(keyHandler, 18, 0, null, false, true, false);
<a name="line559"></a>  fireKeyDown(keyHandler, goog.events.KeyCodes.A, 0, null, false, true,
<a name="line560"></a>      false);
<a name="line561"></a>  fireKeyPress(keyHandler, 0, 229, null, false, false, false);
<a name="line562"></a>  assertEquals(&#39;should fire a key event with alt key set&#39;,
<a name="line563"></a>      true,
<a name="line564"></a>      keyEvent.altKey);
<a name="line565"></a>  fireKeyUp(keyHandler, 0, 229, null, false, true, false);
<a name="line566"></a>  assertEquals(&#39;alt key should still be set&#39;,
<a name="line567"></a>      true,
<a name="line568"></a>      keyEvent.altKey);
<a name="line569"></a>  fireKeyUp(keyHandler, 18, 0, null, false, false, false);
<a name="line570"></a>}
<a name="line571"></a>
<a name="line572"></a>function testGeckoEqualSign() {
<a name="line573"></a>  goog.userAgent.OPERA = false;
<a name="line574"></a>  goog.userAgent.IE = false;
<a name="line575"></a>  goog.userAgent.GECKO = true;
<a name="line576"></a>  goog.userAgent.CAMINO = false;
<a name="line577"></a>  goog.userAgent.WEBKIT = false;
<a name="line578"></a>  goog.userAgent.MAC = false;
<a name="line579"></a>  goog.userAgent.WINDOWS = true;
<a name="line580"></a>  goog.userAgent.LINUX = false;
<a name="line581"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = false;
<a name="line582"></a>
<a name="line583"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line584"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line585"></a>      function(e) { keyEvent = e; });
<a name="line586"></a>
<a name="line587"></a>  fireKeyDown(keyHandler, 61, 0);
<a name="line588"></a>  fireKeyPress(keyHandler, 0, 61);
<a name="line589"></a>  assertEquals(&#39;= should fire should fire a key event with the keyCode 187&#39;,
<a name="line590"></a>               goog.events.KeyCodes.EQUALS,
<a name="line591"></a>               keyEvent.keyCode);
<a name="line592"></a>  assertEquals(&#39;= should fire a key event with the charCode 61&#39;,
<a name="line593"></a>               goog.events.KeyCodes.FF_EQUALS,
<a name="line594"></a>               keyEvent.charCode);
<a name="line595"></a>}
<a name="line596"></a>
<a name="line597"></a>function testMacGeckoSlash() {
<a name="line598"></a>  goog.userAgent.OPERA = false;
<a name="line599"></a>  goog.userAgent.IE = false;
<a name="line600"></a>  goog.userAgent.GECKO = true;
<a name="line601"></a>  goog.userAgent.CAMINO = false;
<a name="line602"></a>  goog.userAgent.WEBKIT = false;
<a name="line603"></a>  goog.userAgent.MAC = true;
<a name="line604"></a>  goog.userAgent.WINDOWS = false;
<a name="line605"></a>  goog.userAgent.LINUX = false;
<a name="line606"></a>  goog.events.KeyHandler.USES_KEYDOWN_ = false;
<a name="line607"></a>
<a name="line608"></a>  var keyEvent, keyHandler = new goog.events.KeyHandler();
<a name="line609"></a>  goog.events.listen(keyHandler, goog.events.KeyHandler.EventType.KEY,
<a name="line610"></a>      function(e) { keyEvent = e; });
<a name="line611"></a>
<a name="line612"></a>  fireKeyDown(keyHandler, 0, 63, null, false, false, true);
<a name="line613"></a>  fireKeyPress(keyHandler, 0, 63, null, false, false, true);
<a name="line614"></a>  assertEquals(&#39;/ should fire a key event with the keyCode 191&#39;,
<a name="line615"></a>               goog.events.KeyCodes.SLASH,
<a name="line616"></a>               keyEvent.keyCode);
<a name="line617"></a>  assertEquals(&#39;? should fire a key event with the charCode 63&#39;,
<a name="line618"></a>               goog.events.KeyCodes.QUESTION_MARK,
<a name="line619"></a>               keyEvent.charCode);
<a name="line620"></a>}
<a name="line621"></a>
<a name="line622"></a>function testGetElement() {
<a name="line623"></a>  var target = goog.dom.createDom(&#39;div&#39;);
<a name="line624"></a>  var target2 = goog.dom.createDom(&#39;div&#39;);
<a name="line625"></a>  var keyHandler = new goog.events.KeyHandler();
<a name="line626"></a>  assertNull(keyHandler.getElement());
<a name="line627"></a>
<a name="line628"></a>  keyHandler.attach(target);
<a name="line629"></a>  assertEquals(target, keyHandler.getElement());
<a name="line630"></a>
<a name="line631"></a>  keyHandler.attach(target2);
<a name="line632"></a>  assertNotEquals(target, keyHandler.getElement());
<a name="line633"></a>  assertEquals(target2, keyHandler.getElement());
<a name="line634"></a>
<a name="line635"></a>  var doc = goog.dom.getDocument();
<a name="line636"></a>  keyHandler.attach(doc);
<a name="line637"></a>  assertEquals(doc, keyHandler.getElement());
<a name="line638"></a>
<a name="line639"></a>  keyHandler = new goog.events.KeyHandler(doc);
<a name="line640"></a>  assertEquals(doc, keyHandler.getElement());
<a name="line641"></a>
<a name="line642"></a>  keyHandler = new goog.events.KeyHandler(target);
<a name="line643"></a>  assertEquals(target, keyHandler.getElement());
<a name="line644"></a>}
<a name="line645"></a>
<a name="line646"></a>function testDetach() {
<a name="line647"></a>  var target = goog.dom.createDom(&#39;div&#39;);
<a name="line648"></a>  var keyHandler = new goog.events.KeyHandler(target);
<a name="line649"></a>  assertEquals(target, keyHandler.getElement());
<a name="line650"></a>
<a name="line651"></a>  fireKeyDown(keyHandler, 0, 63, null, false, false, true);
<a name="line652"></a>  fireKeyPress(keyHandler, 0, 63, null, false, false, true);
<a name="line653"></a>  keyHandler.detach();
<a name="line654"></a>
<a name="line655"></a>  assertNull(keyHandler.getElement());
<a name="line656"></a>  // All listeners should be cleared.
<a name="line657"></a>  assertNull(keyHandler.keyDownKey_);
<a name="line658"></a>  assertNull(keyHandler.keyPressKey_);
<a name="line659"></a>  assertNull(keyHandler.keyUpKey_);
<a name="line660"></a>  // All key related state should be cleared.
<a name="line661"></a>  assertEquals(&#39;Last key should be -1&#39;, -1, keyHandler.lastKey_);
<a name="line662"></a>  assertEquals(&#39;keycode should be -1&#39;, -1, keyHandler.keyCode_);
<a name="line663"></a>}
<a name="line664"></a>
<a name="line665"></a>function testCapturePhase() {
<a name="line666"></a>  var gotInCapturePhase;
<a name="line667"></a>  var gotInBubblePhase;
<a name="line668"></a>
<a name="line669"></a>  var target = goog.dom.createDom(&#39;div&#39;);
<a name="line670"></a>  goog.events.listen(
<a name="line671"></a>      new goog.events.KeyHandler(target, false /* bubble */),
<a name="line672"></a>      goog.events.KeyHandler.EventType.KEY,
<a name="line673"></a>      function() {
<a name="line674"></a>        gotInBubblePhase = true;
<a name="line675"></a>        assertTrue(gotInCapturePhase);
<a name="line676"></a>      });
<a name="line677"></a>  goog.events.listen(
<a name="line678"></a>      new goog.events.KeyHandler(target, true /* capture */),
<a name="line679"></a>      goog.events.KeyHandler.EventType.KEY,
<a name="line680"></a>      function() {
<a name="line681"></a>        gotInCapturePhase = true;
<a name="line682"></a>      });
<a name="line683"></a>
<a name="line684"></a>  goog.testing.events.fireKeySequence(target, goog.events.KeyCodes.ESC);
<a name="line685"></a>  assertTrue(gotInBubblePhase);
<a name="line686"></a>}
<a name="line687"></a>
<a name="line688"></a>function fireKeyDown(keyHandler, keyCode, opt_charCode, opt_keyIdentifier,
<a name="line689"></a>    opt_ctrlKey, opt_altKey, opt_shiftKey) {
<a name="line690"></a>  var fakeEvent = createFakeKeyEvent(
<a name="line691"></a>      goog.events.EventType.KEYDOWN, keyCode, opt_charCode, opt_keyIdentifier,
<a name="line692"></a>      opt_ctrlKey, opt_altKey, opt_shiftKey);
<a name="line693"></a>  keyHandler.handleKeyDown_(fakeEvent);
<a name="line694"></a>  return fakeEvent.returnValue_;
<a name="line695"></a>}
<a name="line696"></a>
<a name="line697"></a>function fireKeyPress(keyHandler, keyCode, opt_charCode, opt_keyIdentifier,
<a name="line698"></a>    opt_ctrlKey, opt_altKey, opt_shiftKey) {
<a name="line699"></a>  var fakeEvent = createFakeKeyEvent(
<a name="line700"></a>      goog.events.EventType.KEYPRESS, keyCode, opt_charCode,
<a name="line701"></a>      opt_keyIdentifier, opt_ctrlKey, opt_altKey, opt_shiftKey);
<a name="line702"></a>  keyHandler.handleEvent(fakeEvent);
<a name="line703"></a>  return fakeEvent.returnValue_;
<a name="line704"></a>}
<a name="line705"></a>
<a name="line706"></a>function fireKeyUp(keyHandler, keyCode, opt_charCode, opt_keyIdentifier,
<a name="line707"></a>    opt_ctrlKey, opt_altKey, opt_shiftKey) {
<a name="line708"></a>  var fakeEvent = createFakeKeyEvent(
<a name="line709"></a>      goog.events.EventType.KEYUP, keyCode, opt_charCode,
<a name="line710"></a>      opt_keyIdentifier, opt_ctrlKey, opt_altKey, opt_shiftKey);
<a name="line711"></a>  keyHandler.handleKeyup_(fakeEvent);
<a name="line712"></a>  return fakeEvent.returnValue_;
<a name="line713"></a>}
<a name="line714"></a>
<a name="line715"></a>function createFakeKeyEvent(type, keyCode, opt_charCode, opt_keyIdentifier,
<a name="line716"></a>    opt_ctrlKey, opt_altKey, opt_shiftKey) {
<a name="line717"></a>  var event = {
<a name="line718"></a>    type: type,
<a name="line719"></a>    keyCode: keyCode,
<a name="line720"></a>    charCode: opt_charCode || undefined,
<a name="line721"></a>    keyIdentifier: opt_keyIdentifier || undefined,
<a name="line722"></a>    ctrlKey: opt_ctrlKey || false,
<a name="line723"></a>    altKey: opt_altKey || false,
<a name="line724"></a>    shiftKey: opt_shiftKey || false,
<a name="line725"></a>    timeStamp: goog.now()
<a name="line726"></a>  };
<a name="line727"></a>  return new goog.events.BrowserEvent(event);
<a name="line728"></a>}
</pre>


</body>
</html>
